package wh.jf.singleton;

public class Singleton3 {
  private volatile static Singleton3 instance; // 多线程 可见 每个线程在修改这个变量之后，会把修改的值同步到主存中
  private Singleton3 () {}
  public static Singleton3 getInstance () {
    if (instance == null) {
      synchronized (Singleton3.class) {
        if (instance == null) {
            instance = new Singleton3();
        }
      }
    }
    return instance;
  }
}
